
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import GameBoard.BasicGameBoard;
import GameBoard.GameBoard;
import GameElements.Tile;
import Player.HumanPlayer;
import Player.IAPlayer;
import Player.Player;
import Player.IAStrategy.IAGloutonStrategy;


public class FenetreTmp extends JFrame
{
	private GameBoard gameTable = new BasicGameBoard();
	
	public FenetreTmp()
	{
		initFenetre("Editeur UML", 800, 600);
		initContenu();
	}
	
	private void initFenetre(String titre, int largeur, int hauteur)
	{
		this.setTitle(titre);
		this.setSize(largeur, hauteur);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}
	
	private void initContenu()
	{
		JPanel panelPrincipale = new JPanel(null);
		
		tmp(panelPrincipale);
		//printPawn(panelPrincipale);
		this.setContentPane(panelPrincipale);
	}
	
	private void testRotate(JPanel panelPrincipale)
	{
		Tile t1 = gameTable.getStock().get(0);
		panelPrincipale.add(t1.getImgLabel());
		t1.rotate90();
		panelPrincipale.add(t1.getImgLabel());
		t1.rotate90();
		panelPrincipale.add(t1.getImgLabel());
		t1.rotate90();
		panelPrincipale.add(t1.getImgLabel());
		t1.rotate90();
		panelPrincipale.add(t1.getImgLabel());
	}
	
	
	private void printStock(JPanel panelPrincipale)
	{
		Vector<Tile> stock = gameTable.getStock();
		for(int i=0; i<stock.size(); i++)
			panelPrincipale.add(stock.get(i).getImgLabel());
	}
	
	private void tmp(JPanel panelPrincipale)
	{
		Vector<Tile> stock = gameTable.getStock();
		Tile[][] table = gameTable.getTable();
		Player p = new IAPlayer("s", new IAGloutonStrategy());
		Vector<Player> ps = new Vector<Player>();
		ps.add(p);
		gameTable.distributePawn(ps);
		while(stock.size() != 0)
		{
			p.play(gameTable);
		}
		
		for(int i=0 ; i< table.length; i++)
			for(int j=0 ; j< table[0].length; j++)
				if(table[i][j] != null)
				{
					JLabel l = table[i][j].getImgLabel();
					l.setBounds((i) * 80, (j-1) * 80, 80, 80);
					panelPrincipale.add(l);
				}
	}
}
